/** 
 * All Rights Reserved , Copyright (C) 2020 , 青岛鼎信通讯股份有限公司
 * 
 *MpmProjectTaskTemplateController
 * 任务模板
 * 
 * 修改纪录
 * 2020-12-25 版本：1.0 lanjianwei 创建。
 * @version 版本：1.0
 * @author 作者：lanjianwei
 * 创建日期：2020-12-25
 */

package com.topscomm.mpm.controller;

import com.topscomm.basic.exception.MessageException;
import com.topscomm.mpm.pojo.MpmProjectTaskTemplateEntity;
import com.topscomm.pub.util.ConvertUtil;
import java.util.Map;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.topscomm.mpm.controller.auto.MpmProjectTaskTemplateControllerAuto;
import com.topscomm.pub.util.StringBufferProxy;
import com.topscomm.pub.util.StringUtil;
import com.topscomm.pub.vo.ResponseResult;

/**
 * @author: lanjianwei
 * @date: 2020-12-25
 * @description:任务模板Controller
 * @modify:
 */
@RestController
@RequestMapping("mpm/projectTaskTemplate")
public class MpmProjectTaskTemplateController extends MpmProjectTaskTemplateControllerAuto implements IMpmProjectTaskTemplateController {
	/**
	 * @author: lanjianwei
	 * @date: 2020-12-25
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	protected String spellListSql(Map<String, Object> paraMap) {
		StringBufferProxy sql = new StringBufferProxy();
		sql.appendSingle(" 1=1 ");
		if (paraMap.containsKey("qry_name")) {
			String value = paraMap.get("qry_name").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and taskname like '%{0}%' ", value);
		}
		if (paraMap.containsKey("qry_tasktype")) {
			String value = paraMap.get("qry_tasktype").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and tasktype = '{0}' ", value);
		}
		if (paraMap.containsKey("qry_taskname")) {
			String value = paraMap.get("qry_taskname").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and taskname like '%{0}%' ", value);
		}
		if (paraMap.containsKey("qry_mileposttemplateid")) {
			String value = paraMap.get("qry_mileposttemplateid").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and mileposttemplateid = '{0}' ", value);
		}
		if (paraMap.containsKey("qry_taskpriority")) {
			String value = paraMap.get("qry_taskpriority").toString();
			if (!StringUtil.isEmpty(value))
				sql.appendSingle(" and taskpriority = '{0}' ", value);
		}
		return sql.toString();
	}

	/**
	 * @author: lanjianwei
	 * @date: 2020-12-25
	 * @param paraMap
	 * @return
	 * @description:转换出查询SQL语句
	 * @modify:
	 */
	@Override
	@GetMapping(value = "/refList")
	public ResponseResult<Object> refList(@RequestParam(required = false) Map<String, Object> paraMap) {
		return super.refList(paraMap);
	}

	protected void beforeInsert(Map<String, Object> dataMap, Map<String, Object> paraMap) throws Exception {
		String str = paraMap.get("sortcode").toString();
		for(int i=0;i<str.length();i++){
			if(!Character.isDigit(str.charAt(i))){
				throw new MessageException("输入的序号必须为数字！");
			}
		}
	}
}

